﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/QuizAdmin.Master" AutoEventWireup="true" CodeBehind="EditQuiz.aspx.cs" Inherits="BladeTecWebApplication.Admin.EditQuiz" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">

<script type="text/javascript">
$(function () {
	$('#tabs').tabs();
	$('#tabs1').tabs();

	$('#errorDialog').dialog({
		autoOpen: false,
		width: 400,
		modal: true,
		buttons: {
			"Ok": function () {
				$(this).dialog("close");
			}
		}
	});

	$("#MainContent_ddlCategory").change(toggle);
	$("#MainContent_ddlLevel").change(toggle);

});

function toggleQuestionDiv(selected, questionId) {
	if (selected) {
		$("#questionTable" + questionId).toggleClass('questionTableSelected', true);
	} else {
		$("#questionTable" + questionId).toggleClass('questionTableSelected', false);
	}
}

function openPrint() {
	window.open('PrintQuiz.aspx?quiz_id='+$("#MainContent_hfQuizId").val(), 'print_quiz');
}

function validatePage() {
	var title = $("#MainContent_txtQuizTitle").val();
	if (title == '') {
		$('#errorDialog').dialog('open');
		return false;
	}
}


function toggle() {
	var categoryId = $("#MainContent_ddlCategory").val();
	var levelId = $("#MainContent_ddlLevel").val();
	$("div[divtype=questionDiv]").show();
	if (categoryId != '-1') {
		$("div[divtype=questionDiv][category!=" + categoryId + "]").hide();
	}
	if (levelId != '-1') {
		$("div[divtype=questionDiv][level!=" + levelId + "]").hide();
	}
}

</script>

</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

<span class="pageTitle">Edit Quiz</span>
<br /><br />

<asp:Panel ID="pnlQuizSettings" runat="server">

	<table cellpadding="0" cellspacing="0" border="0" width="100%">
		<tr>
			<td>
				<div id="tabs" style="width: 600px;">
					<ul>
						<li><a href="#tabs-1">Quiz Information</a></li>
					</ul>
					<div id="tabs-1">
						<table cellpadding="0" cellspacing="0" border="0">
							<tr>
								<td>Quiz Title:<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="*" ForeColor="Red" ControlToValidate="txtQuizTitle"></asp:RequiredFieldValidator></td>
								<td style="width: 10px;">&nbsp;</td>
								<td><asp:TextBox ID="txtQuizTitle" runat="server" Width="350px" CssClass="stdTextBox"></asp:TextBox></td>
							</tr>
						</table>
					</div>
				</div>
			</td>
			<td style="text-align:right; vertical-align:top;" nowrap="nowrap">
				<table cellpadding="0" cellspacing="0" border="0">
					<tr>
						<td valign="top"><span class="ui-icon ui-icon-print"></span></td>
						<td style="width:5px;">&nbsp;</td>
						<td style="padding-bottom:5px;"><a class="dashboardLink" href="javascript:openPrint();">Print</a></td>
					</tr>
				</table>
			</td>
		</tr>
	</table>

	<br />
	<br />

	<div id="tabs1">
		<ul>
			<li><a href="#tabs-2">Question Bank</a></li>
		</ul>
		<div id="tabs-2" style="width:1000px;">
			The list below shows all of the available questions that can be added to the quiz. The list can be filtered by category or by question level.
			Questions that have already been added to the quiz are shaded red. Selecting a question to be added to the quiz will shade the question grey.
			<br /><br />		
			<table cellpadding="0" border="0" cellspacing="0">
				<tr>
					<td>Filter Answers by Category:</td>
					<td style="padding-left: 10px;"><asp:DropDownList ID="ddlCategory" ClientIDMode="Predictable" runat="server"></asp:DropDownList></td>

					<td style="padding-left: 20px;">Filter Answers by Level:</td>
					<td style="padding-left: 10px;"><asp:DropDownList ID="ddlLevel" ClientIDMode="Predictable" runat="server"></asp:DropDownList></td>
				</tr>
			</table>
			<br />
			
			<table class="netsysTable" cellspacing="0" rules="all" id="MainContent_gvApplicants" style="border-width:0px;border-style:None;width:100%;border-collapse:collapse; margin-bottom:5px;">
				<tr>
					<th style="width:5px; text-align:left;">&nbsp;</th>
					<th style="width:700px; text-align:left;">Question</th>
					<th style="width:100px; text-align:left;">Level</th>
					<th style="width:200px; text-align:left;">Category</th>
				</tr>
			</table>
			<asp:Panel ID="pnlQuestions" runat="server">
			</asp:Panel>

		</div>
	</div>

	<br />

	<div style="text-align:right;">
		<br />
		<asp:Button ID="btnSaveQuiz" runat="server" Text="Save Quiz" 
			onclick="btnSaveQuiz_Click" OnClientClick="validatePage();"/>
	</div>

</asp:Panel>

<asp:HiddenField runat="server" ID="hfQuizId" />

<asp:Panel Visible="false" ID="pnlResult" runat="server">
	Quiz <asp:Label Font-Bold="true" ID="quizName" runat="server"></asp:Label> was updated.
	<br /><br />
	<a href="ViewQuizzes.aspx" class="dashboardLink">View Quizzes</a>
</asp:Panel>

<div id="errorDialog" title="No Quiz Title">
	Please enter a quiz title.
</div>

</asp:Content>
